<template>
  <div :class="['message', isAi ? 'ai-message' : 'user-message']">
    <div class="avatar">
      <a-avatar :src="isAi ? '/ai-avatar.png' : '/user-avatar.png'" />
    </div>
    <div class="content">
      <div class="bubble">
        {{ message.content }}
      </div>
      <div class="timestamp">
        {{ message.timestamp }}
      </div>
    </div>
  </div>
</template>

<script setup>
defineProps({
  message: {
    type: Object,
    required: true
  },
  isAi: {
    type: Boolean,
    default: false
  }
})
</script>

<style scoped>
.message {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.ai-message {
  align-self: flex-start;
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  flex-shrink: 0;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-message .bubble {
  background-color: #f0f0f0;
  padding: 12px;
  border-radius: 18px 18px 18px 4px;
}

.user-message .bubble {
  background-color: #1890ff;
  color: white;
  padding: 12px;
  border-radius: 18px 18px 4px 18px;
}

.timestamp {
  font-size: 12px;
  color: #999;
}
</style>
